package corp.edu.amadeus.core.schedule.sender.broadcast;

import java.util.TimerTask;
import corp.edu.amadeus.utils.log.LogTracer;
import org.apache.log4j.Logger;

import corp.edu.amadeus.core.bluetooth.sender.broadcast.Broadcaster;


public class BroadcastSenderTask extends TimerTask {

	private static Logger log = Logger.getLogger(BroadcastSenderTask.class);
	private static Broadcaster broadcaster;

	public BroadcastSenderTask(String ct_path, String ct_name) {
		broadcaster = new Broadcaster(ct_path, ct_name);
	}

	@Override
	public void run() {
		log.debug("++++ Launching  BroadcastSenderTask");
		if(broadcaster.isSending()) {
			log.debug("Sending job is active, cancel these one.");
			return;
		}
		try {
			broadcaster.send();
		} catch(Exception e) {
			LogTracer.printStackTraceError(e, log);
		}
	}

}